package com.winbomb.kingcard.base.anim.impl;

import com.winbomb.kingcard.Action;
import com.winbomb.kingcard.Assets;
import com.winbomb.kingcard.IGameLogic;
import com.winbomb.kingcard.IPlayer;
import com.winbomb.kingcard.Pos;
import com.winbomb.kingcard.base.GameLogic;
import com.winbomb.kingcard.base.anim.IPlayable;
import com.winbomb.kingcard.framework.Graphics;

public class ActionAnim implements IPlayable {

	private Graphics g;
	private int actionY;
	private Pos tgPos;
	private float delay;

	public ActionAnim(IGameLogic game) {
		this.delay = 0;
		this.g = ((GameLogic) game).getRender().getGraphics();
	}

	public void setTargetPlayer(IPlayer tgPlayer) {
		this.tgPos = tgPlayer.getPlayerInfo().getFramePos();
	}

	public void setAction(Action action) {
		switch (action) {
		case BATTLE:
			actionY = 0;
			break;

		case REST:
			actionY = 22;
			break;

		case SEND_OUT:
			actionY = 44;
			break;

		case CALL_UP:
			actionY = 66;
			break;

		case TAKE_POWER:
			actionY = 88;
			break;

		case CHASE_ATTACK:
			actionY = 110;
			break;

		case WITHDRAW:
			actionY = 132;
			break;
		}
	}

	public void reset() {
		this.delay = 0;
		this.tgPos = null;
	}

	@Override
	public boolean play(float dt) {

		if (delay <= 1000.0f) {
			g.drawPixmap(Assets.actions, tgPos.x, tgPos.y, 0, actionY, 54, 22);
			delay += dt;
			return false;
		}

		return true;
	}

}
